package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import com.lagou.rpc.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author boting.guo
 * @date 2021/11/6 23:32
 */

@RestController
@RequestMapping("user")
public class UserController {

   private IUserService userService = (IUserService) RpcClientProxy.createProxy(IUserService.class);

   @GetMapping("{id}")
   public User getById(@PathVariable("id") int id) {
      User user = userService.getById(id);
      System.out.println(user);
      return user;
   }
}
